package cn.lyf.myblog.controller.api;

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.node.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static cn.lyf.myblog.controller.api.JsonUtils.*;
import cn.lyf.myblog.service.*;

@RestController
public class CommentApi {


    @Autowired
    CommentService commentService;

    @PostMapping("/comments/blog")
    JsonNode getBlogComment(@RequestBody JsonNode json) throws Exception {
        try {
            return commentService.getCommentsInfo(json.deepCopy());
        } catch (Exception e) {
            e.printStackTrace();
            ObjectNode res = mapper.createObjectNode();
            res.put("success", false);
            res.put("code", 463);
            res.put("message", "评论获取失败！");
            return res;
        }
    }

}
